<template>
    <div v-show="visible">属性测试：{{myProp.msg}}</div>
</template>

<script lang="ts">
import {defineComponent, PropType} from 'vue';

export interface PropTestProps{
    msg: string
}
export default defineComponent({
    props: {
        myProp: {
            type: Object as PropType<PropTestProps>,
            default: {msg:'默认消息'}
        },
        visible: Boolean
    },
    emits:['update:visible'],
    data(){
        return {
            show:true,
            timeDelay: 0
        };
    },
    mounted(): void {
        this.timeDelay = setInterval(()=>{
            this.show  = !this.show;
            this.$emit('update:visible', this.show);
        }, 2000);
    },
    beforeDestroy(): void{
        clearInterval(this.timeDelay);
    }
})
</script>

